package com.song.demo04springbootweb.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;

@Controller
@RequestMapping("/hello")
public class TestController {

    /*http://localhost:8888/hello/test*/
    @GetMapping("/test")
    public String test(){
        return "test";
    }


    /*导入 thymeleaf-stater，就可以实现跳转，访问到templates文件下的首页了*/
    /*http://localhost:8888/hello/index*/
    @GetMapping("/index")
    public String test1(Model model){
        // 数据放入model中，在首页index.html通过thymeleaf取出这个消息
        model.addAttribute("msg","hello,springboot");
        model.addAttribute("msg1","<h1>hello,springboot</h1>");
        model.addAttribute("msg2","<h1>hello,springboot</h1>");
        model.addAttribute("userList", Arrays.asList("张三","李四","王五"));
        return "index";
    }
}
